package com.cjl.demo.juc;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * <p>Copyright: All Rights Reserved</p>
 * <p>1.什么是CAS ? ===> compareAndSet
 *  *   比较并交换</p>
 *
 * @ uthor chenjinliang
 * @ date: 2020/2/16
 */
public class CASDemo {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(5);
        System.out.println(atomicInteger.compareAndSet(5, 2019) + "\t current" + atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(5, 2014) + "\t current" + atomicInteger.get());
    }
}
